﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using IQKS.AWP.BusinessObject;
using System.Data.SqlClient;

namespace IQKS.AWP.DataAccessLayer
{
   public class EmailByStatusDAL
    {
       public DataSet GetEmailDataByStatus(EmailByStatusBO param)
        {
            DataSet objDs;

            try
            {

                SqlParameter[] parameters = new SqlParameter[]
               {
                  new SqlParameter("@ActivityID",param.ActivityID),
                  new SqlParameter("@EmailTemplateID", param.EmailTemplateID),
                  new SqlParameter("@EmailStatusID", param.EmailStatusID)              
              };
                objDs = DataUtils.ExecuteDataset("USP_EmailSearchByStatus", parameters);

            }
            catch (Exception exception)
            {
                throw new ApplicationException(exception.Message);
            }
            return objDs;
        }


        public DataSet GetActivityName(params object[] param)
        {
            DataSet objDs;

            try
            {
                objDs = DataUtils.ExecuteDataset("USP_GetActivityName", param);

            }
            catch (Exception exception)
            {
                throw new ApplicationException(exception.Message);
            }
            return objDs;
        }

        public DataSet GetActivityByName(params object[] param)
        {
            DataSet objDs;

            try
            {
                objDs = DataUtils.ExecuteDataset("USP_GetActivityByName", param);

            }
            catch (Exception exception)
            {
                throw new ApplicationException(exception.Message);
            }
            return objDs;
        }

        public DataSet GetAllEmailSentStatus(params object[] param)
        {
            DataSet objDs;

            try
            {
                objDs = DataUtils.ExecuteDataset("USP_GetAllEmailSentStatus", param);

            }
            catch (Exception exception)
            {
                throw new ApplicationException(exception.Message);
            }
            return objDs;
        }

        public DataSet GetEmailTemplateId(params object[] param)
        {
            DataSet objDs;

            try
            {
                objDs = DataUtils.ExecuteDataset("Usp_GetEmailTemplateIdByEmailSubject", param);

            }
            catch (Exception exception)
            {
                throw new ApplicationException(exception.Message);
            }
            return objDs;
        }
        

        public DataSet GetActivityEmailTemplateNameByActivity(params object[] param)
        {
            try
            {
                return DataUtils.ExecuteDataset("USP_GetEmailTemplateNameByActivity", param);
            }
            catch (Exception ex)
            {
                throw new ApplicationException(ex.Message);
            }
        }

        public object SetResendEmails(EmailByStatusBO param)
        {
            try
            {

                SqlParameter[] parameters = new SqlParameter[]
               {
                  new SqlParameter("@SetMethod",param.SetMethod),
                  new SqlParameter("@EmailSentCode", param.EmailSentCode),
                  new SqlParameter("@EmailQueueIDs", param.EmailQueueIDs),
                  new SqlParameter("@CreatedBy",param.CreatedBy),
                 
              };
                return DataUtils.ExecuteScalar("Usp_SetResendEmail", parameters);
            }
            catch (Exception ex)
            {
                throw new ApplicationException(ex.Message);
            }
        }
    }
}
